package van.planifolia.singleton;

/**
 * Created by Intellij IDEA<br>
 *
 * @author Planifolia.Van
 * @version 1.0
 * @date 2022/11/7 17:55
 */
public class LazyManV1 {
    /**
     * 首先还是声明一个对象引用
     */
    private static LazyManV1 lazyManV1;

    /**
     * 私有化构造方法
     */
    private LazyManV1() {
    }

    /**
     * 提供一个外接获取的
     *
     * @return 创建的bean对象
     */
    public static synchronized LazyManV1 getBean() {
        if (lazyManV1 == null) {
            lazyManV1 = new LazyManV1();
        }
        return lazyManV1;
    }

    public static void main(String[] args) {
        for(int i = 0; i < 100; i++) {
           new Thread(()->System.out.println(LazyManV2.getBean())).start();
        }
    }
}
